package com.clkj.cldisabledmanclient.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.clkj.cldisabledmanclient.R;
import com.clkj.cldisabledmanclient.bean.custombean.IndexApplyItem;

import java.util.List;

/**
 * Created by clboys on 2019/5/16.
 */

public class GvAdapterForApply extends BaseAdapter {

    List<IndexApplyItem> data;
    Context mContext;
    LayoutInflater mLayoutInflater;


    public GvAdapterForApply(List<IndexApplyItem> data, Context mContext) {
        this.data = data;
        this.mContext = mContext;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;

        if (convertView == null) {
            convertView = mLayoutInflater.inflate(R.layout.item_apply, null);
            viewHolder = new ViewHolder();
            //view的初始化

            viewHolder.ivApplyPic = (ImageView) convertView.findViewById(R.id.iv_apply_pic);
            viewHolder.tvApplyName = (TextView) convertView.findViewById(R.id.tv_apply_name);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        IndexApplyItem indexApplyItem = data.get(position);

        viewHolder.tvApplyName.setText(indexApplyItem.getApplyName());

        Glide.with(mContext)
                .load(indexApplyItem.getApplyPicResId())
                .into(viewHolder.ivApplyPic);
        return convertView;
    }


    static class ViewHolder {

        private ImageView ivApplyPic;
        private TextView tvApplyName;





    }
}

